package com.buaa.wangrui.client;

import com.buaa.wangrui.client.panel.LoginPanel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.MessageBox;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.Viewport;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.form.Label;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.grid.GridPanel;
import com.gwtext.client.widgets.layout.BorderLayout;
import com.gwtext.client.widgets.layout.BorderLayoutData;
import com.gwtext.client.widgets.layout.FitLayout;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.RegionPosition;

public class Login implements EntryPoint {

	private Panel loginMainPanel, borderPanel, northPanel;

	public void onModuleLoad() {

		// creatMainPanel();
		// createPanel_1();

		loginMainPanel = new Panel();
		loginMainPanel.setBorder(false);
		loginMainPanel.setPaddings(10);
		loginMainPanel.setLayout(new FitLayout());
		//loginMainPanel.setSize(1420, 750);
		borderPanel = new Panel();
		borderPanel.setBorder(false);
		borderPanel.setLayout(new BorderLayout());

//		createNorthPanel();
//		createSouthPanel();
//		createWestPanel();
//		createEastPanel();
//		createCenterPanel();

		LoginPanel login = new LoginPanel();
		login.show();

//		loginMainPanel.add(borderPanel);
//		RootPanel.get().add(loginMainPanel);
		// Viewport p = new Viewport(loginMainPanel);

	}

	private void createNorthPanel() {

		northPanel = new Panel();
		northPanel.setBorder(false);
		northPanel.setHeight(250);
		northPanel.setId("northPanel");
		northPanel.setStyleName("");
		borderPanel.add(northPanel, new BorderLayoutData(RegionPosition.NORTH));

	}

	private void createSouthPanel() {

		Panel southPanel = new Panel();
		southPanel.setBorder(false);
		southPanel.setHeight(250);
		southPanel.setId("southPanel");
		southPanel.setStyleName("");
		borderPanel.add(southPanel, new BorderLayoutData(RegionPosition.SOUTH));

	}

	private void createWestPanel() {

		Panel westPanel = new Panel();
		westPanel.setBorder(false);
		westPanel.setWidth(500);
		westPanel.setId("westPanel");
		westPanel.setStyleName("");
		borderPanel.add(westPanel, new BorderLayoutData(RegionPosition.WEST));

	}

	private void createEastPanel() {

		Panel eastPanel = new Panel();
		eastPanel.setBorder(false);
		eastPanel.setWidth(500);
		eastPanel.setId("eastPanel");
		eastPanel.setStyleName("");
		borderPanel.add(eastPanel, new BorderLayoutData(RegionPosition.EAST));

	}

	private void createCenterPanel() {

		Panel centerPanel = new Panel();
		centerPanel.setBorder(false);
		centerPanel.setStyleName("");
		borderPanel.add(centerPanel,new BorderLayoutData(RegionPosition.CENTER));

	}

	// public void welcomePanel(){
	//		
	// final Label welcomeLabel = new Label("Welcome !");
	//		
	// RootPanel.get().clear();
	//		
	// RootPanel.get().add(welcomeLabel);
	// }
	//	
	// public void creatMainPanel() {
	//
	// Panel mainPanel = new Panel();
	//
	// mainPanel.setPaddings(10);
	//
	// final FormPanel formPanel = new FormPanel();
	//
	// formPanel.setTitle("登陆");
	//
	// formPanel.setFrame(true);
	//
	// formPanel.setClosable(true);
	//
	// TextField txtName = new TextField("用户名", "txtName", 80);
	//
	// TextField txtPsw = new TextField("密码", "txtPsw", 80);
	//
	// txtPsw.setPassword(true);
	//
	// Button btLogin = new Button("登陆");
	//
	// btLogin.addListener(new ButtonListenerAdapter() {
	//
	// public void onClick(Button button,EventObject e) {
	//				
	// if(formPanel.getForm().isValid()){
	//					
	// MessageBox.alert("登陆成功");
	//					
	// welcomePanel();
	// }
	// else
	// MessageBox.alert("登陆失败");
	//
	// }
	// });
	//
	// formPanel.add(txtName);
	//
	// formPanel.add(txtPsw);
	//
	// formPanel.add(btLogin);
	//
	// mainPanel.add(formPanel);
	//
	// // Viewport p = new Viewport(mainPanel);
	//		
	// RootPanel.get().add(mainPanel);
	// }
	//	
	// public void createPanel_1(){
	//		
	// Grid gridPanel = new Grid(51,51);
	//		
	// gridPanel.setBorderWidth(2);
	//		
	// Panel panel = new Panel("登陆");
	//		
	// panel.setSize(100, 100);
	//		
	// gridPanel.setWidget(46, 26, panel);
	//		
	// RootPanel.get().add(gridPanel);
	//		
	// }

}